<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class admin_system extends MX_Controller
{
	function admin_system()
	{
		parent::__construct();
		$this->check_login();
		$this->load->model('mod_lib');
	}
	
	function index()
	{
		$data['title']			= 'Quản Lý Cấu Hình Website';
		$data['admin_config']	= $this->db->get_where('configs', array())->result_array();
		if ($this->input->post('cmd'))
		{
			$lock_web 	= 0;
			if ($this->input->post('lock_website')=="on")
			{
				$lock_web 	= 1;
			}
			$data	= array(
							'lock_web'				=> $lock_web,
							'message'				=> $this->input->post('message_lock_website'),
							'name_web'				=> $this->input->post('title_website'),
							'desc_web'				=> $this->input->post('desc_website'),
							'copyright'				=> $this->input->post('copyright'),
							'contact'				=> '',
							'keyword'				=> $this->input->post('key_word'),
							'quanity_support_yahoo'	=> '',
							'quanity_support_skype'	=> '',
							'com_name'				=> $this->input->post('com_name'),
							'com_address'			=> $this->input->post('com_address'),
							'logo'					=> $this->input->post('image'),
							'footer'				=> $this->input->post('footer'),
							'com_tel'				=> $this->input->post('com_tel'),
							'com_fax'				=> $this->input->post('com_fax'),
							'email'					=> $this->input->post('email'),
							'hotline'				=> $this->input->post('hotline'),
							'mobile'				=> $this->input->post('mobile'),
							'email_contact'			=> $this->input->post('email_contact'),
							'alexa_id'				=> $this->input->post('alexa_id'),
							'google_analytics'		=> $this->input->post('google_analytics'),
							'favicon'				=> $this->input->post('favicon')
			);
			$this->mod_lib->update('configs', array('id'=>$this->input->post('id')), $data);
			redirect(base_url().'admin_system/admin_system');
		}
		$data['content_admin']	= 'admin_system/index';
		$this->load->view('back_end/template_admin', $data);
	}
	
	function search()
	{
		
	}
	
	function add($id="")
	{
		if ($id == "")
		{
			$data['title'] 		= "Thêm Mới Menu Admin";
			$data['content_admin']	= 'admin_menu/add';
		}
		else
		{
			$data['content_admin']	= 'admin_menu/edit';
		}
		$data['menu_admin']		= $this->mod_lib->load_all('admin_menu', '', array('cat_id'=>0), '', '', array('name'=>'ASC'));
		$this->load->view('back_end/template_admin', $data);
	}
}